package com.laomou.poker;

import com.laomou.poker.rule.PokerRuleType;
import com.laomou.poker.table.ITable;
import com.laomou.poker.table.TableFactory;

public final class PokerGame {
    private static PokerGame mPokerGame;
    private IConfig mConfig;

    private PokerGame(IConfig config) {
        mConfig = config;
    }

    public interface IConfig {
        PokerRuleType getPokerRuleType();

        void config(ITable table);
    }

    public static PokerGame config(IConfig config) {
        if (mPokerGame == null) {
            mPokerGame = new PokerGame(config);
        }
        return mPokerGame;
    }

    public void playGame() {
        ITable mTable = TableFactory.makeTableRule(mConfig.getPokerRuleType());
        if (mTable != null) {
            mConfig.config(mTable);
            mTable.playGame();
        }
    }
}
